home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c++,comp.lang.c
- Subject: Re: compiling problem under g++
- Date: Thu, 04 Apr 96 00:20:30 GMT
- Organization: none
- Message-ID: <828577230snz@genesis.demon.co.uk>
- References: <3161A2D3.7D84@psu.edu> <4jtsdm$hba@nadine.teleport.com>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4jtsdm$hba@nadine.teleport.com> hksys@teleport.com "GHouck" writes:
-
- >"Jason A. Soloff" <jas251@psu.edu> wrote:
- >>Minor problem here... I have been coding in C++ for years on the Dos/win
- >>platforms, and am running into (what has to be) a simple, but annoying
- >>problem...
- >>
- >>#include <math.h>
- >>int main(void)
- >>{
- >> printf("%f\n",sqrt(25));
- >> return 0;
- >>}
- >>
- >>OK... thats it... nice and simple huh? Nope.
- >>Won't compile on two unix systems I am trying to work with...
- >>SunOS 4.1.3_U1, with g++ 2.4 It can't seem to find the
- >>sqrt code from the library? Am I missing something? is the
- >>library called something else under UNIX?
-
- See section 14.3 od the FAQ.
-
- >Jason,
- >
- >If the '25' is truly an integer, perhaps that is the
- >problem, since there probably is no function available
- >to take the square root of an integer, but rather
- >a double. Unless, of course, it casts it, then ...
-
- A C compiler can convert implicitly between integer anf floating point
- types. Since math.h is included an ANSI compiler must perform that conversion
- in the code example. With a pre-ANSI compiler without prototyped standard
- library declarations in header files the compiler wouldn't perform the
- appropriate conversion. On the other hand it is not likely to know enough
- to reject the program at compile time.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-